/*
 * @Descripttion:
 * @version:
 * @Author: 穆宏宇
 * @Date: 2020-09-08 10:21:00
 * @LastEditors: 穆宏宇
 * @LastEditTime: 2020-11-19 16:48:15
 */
import api from './index'
// 导入工具函数	
// eslint-disable-next-line no-unused-vars
import tools from '@/tools'
import config from "@/config"
// 用户ID
// const userId = tools.localRead('userId')
// 公共导航

// 获取一级菜单
export const getMenuList = ({ itemType = 0 }) => {
  const url = `/vapi/index/nav/queryOfficeSupplies?itemType=${itemType}`
  return api.get(url)
}

// 获取2，3级菜单
export const getMenuList23 = ({ itemids = '' }) => {
  const url = `/vapi/index/nav/officeSuppliesinitchild?itemids=${itemids}`
  return api.get(url)
}

// 首页楼层数据列表
export const getGoods = (data, page = 1, size = 10) => {
  const url = `/api/search/itemSearch?page=${page}&size=${size}`
  return api.post(url, data)
}
export const getGoodsMobile = (data, page = 1, size = 9) => {
  const url = `/api/search/itemSearch?page=${page}&size=${size}`
  return api.post(url, data)
}

// 我的评价
export const getMyEvaluate = (params) => {
  const url = `/special/dictionary/evaluate/queryMyEvaluate`
  return api.get(url, params)
}

// 查询导航栏数据
export const getNav = () => {
  const url = `/api/sysNavigation/queryNavigation`
  return api.get(url)
}

// 获取首页轮播图
export const getHomePagePics = () => {
  const url = '/api/dictionary/getHomePagePics'
  return api.get(url)
}

// 获取商品详情
export const getGoodsItem = (id, isIntranet) => {
  const url = `/api/goodsItem/detail?id=${id}&isIntranet=${isIntranet}`
  return api.get(url)
}

// 获取商品详情
export const getGoodsDetail = (id, isIntranet) => {
  const url = `/vapi/item/detail?id=${id}&isIntranet=${isIntranet}`
  return api.get(url)
}

// 获取配送地址json数据
export const getAddress = () => {
  const url = `/special/dictionary/address/queryArea`
  return api.get(url)
}

// 根据code查询省市区
export const getAddressName = (params) => {
  const url = `/api/deliveryAddress/queryAreaNameByCode`
  return api.get(url, params)
}

// 查询商品成交历史
export const getGoodsHistory = (id) => {
  const url = `/api/order/orderByGoodsId?goodsId=${id}`
  return api.get(url)
}

// 详情页商品评价
export const getGoodsEvaluate = (data) => {
  const url = `/api/evaluate/queryEvaluateDetailByGoodsId`
  return api.get(url, data)
}

// 新增/编辑发票
export const saveOrUpdateReceipt = (data) => {
  const url = `/special/dictionary/receipt/saveOrUpdateReceipt`
  return api.post(url, data)
}

// 查询发票
export const queryReceipt = (data) => {
  const url = `/special/dictionary/receipt/queryReceipt`
  return api.get(url, data)
}

// 删除发票
export const deleteReceipt = (id) => {
  const url = `/special/dictionary/receipt/deleteReceipt/${id}`
  return api.delete(url)
}

// 查询省市区
export const queryArea = () => {
  const url = `/special/dictionary/address/queryArea`
  return api.get(url)
}

// 新增/修改地址
export const saveOrUpdateDeliveryAddress = (data) => {
  const url = `/special/dictionary/address/saveOrUpdateDeliveryAddress`
  return api.post(url, data)
}

// 查看收货地址
export const queryDeliveryAddress = () => {
  const url = `/special/dictionary/address/queryDeliveryAddress`
  return api.get(url)
}

// 删除收货地址
export const deleteDeliveryAddress = (id) => {
  const url = `/special/dictionary/address/deleteDeliveryAddress/${id}`
  return api.delete(url)
}

// 设置默认地址
export const updateDefaultAddress = (id) => {
  const url = `/special/dictionary/address/updateDefaultAddress/${id}`
  return api.put(url)
}

// 修改密码
export const updatePassword = (data) => {
  const url = `/special/dictionary/users/updatePasswordByUser/`
  return api.post(url,data)
}

// 新增评价
export const saveEvaluate = (data) => {
  const url = '/api/evaluate/saveEvaluate'
  return api.post(url, data)
}

// 查询购物车内数据数量
export const getShoppingcarNum = () => {
  const url = '/vapi/index/system/cart/queryList'
  return api.get(url)
}

// 购物车列表 采购类型 1:按产品采购 2:按需采购characteristicId
export const getShoppingcarList = (purchcharacteristicIdType) => {
  const url = `/api/orderShoppingCart/${purchaseType}`
  return api.get(url)
}

// 清空购物车 采购类型 1:按产品采购 2:按需采购
export const deleteShoppingcarList = (purchaseType) => {
  const url = `/api/orderShoppingCart/emptyByUserId/${purchaseType}`
  return api.delete(url)
}

// 查询采购分支信息列表 purchaseType:1按产品采购 2按需采购
export const getbranchShowList = (purchaseType) => {
  const url = `/special/dictionary/branch/branchShowList/${purchaseType}`
  return api.get(url)
}

// 添加到购物车
export const addShoppingcar = (data, userId) => {
  // const url = '/api/orderShoppingCart/goods'
  // return api.post(url,{...data,purchaserId: userId})

  const url = '/vapi/cart/goods'
  return api.post(url, { ...data, purchaserId: userId })

}

// 更新购物车
export const putShoppingcar = (data) => {
  // const url = '/api/orderShoppingCart/goods'
  // return api.put(url, data)
  const url = '/vapi/cart/goods'
  return api.put(url, data)
}

// 删除购物车
export const deleteShoppingcar = (id) => {
  // const url = `/api/orderShoppingCart/${id}`
  // return api.delete(url)
  const url = `/vapi/cart/${id}`
  return api.delete(url)
}

// 批量删除购物车商品
export const deleteShoppingcarByIds = (data) => {
  // const url = '/api/orderShoppingCart/removeByIds'
  // return api.post(url,data)
  const url = `/vapi/cart/` + data.join(",")
  return api.delete(url, data)
}

// 购物车页去下单
export const orderCheck = (data) => {
  const url = '/vapi/shoporder/orderCheck'
  // const url = '/api/order/orderCheck'
  return api.post(url, data)
}

// 查询需求列表
export const getDemandList = (params) => {
  const url = `/api/orderShoppingCart/demandList`
  return api.get(url, params)
}

// 保存购物车数据-需求
export const addDemand = (data, userId) => {
  const url = `/api/orderShoppingCart/demand`
  return api.post(url, { ...data, purchaserId: userId })
}

// 提交订单
export const saveOrder = (data) => {
  const url = '/api/purchaseProcess/'
  return api.post(url, data)
}

//生成预占订单
export const savePreOrder = (data) => {
  // const url = '/api/orderApprove/goods'
  const url = '/vapi/shoporder/goods'
  return api.post(url, data)
}

//取消预占
export const cancelOrderApproveResult = (data) => {
  const url = '/api/orderApprove/orderApproveResult'
  return api.post(url, data)
}


// 查询订单列表
export const getOrderList = (params) => {
  const url = `/api/order/demandList`
  return api.get(url, params)
}

// 查询订单列表(电商)
export const getOrderListOnLine = (params) => {
  const url = `/vapi/shoporder/list`
  return api.get(url, params)
}

// 提交委托 / 提交审核 / 确认询价结果
export const purchaseProcess = (data) => {
  const url = '/api/purchaseProcess/'
  return api.post(url, data)
}

// 查询用户ID在的组织
export const getUserOrganization = (userId) => {
  const url = `/api/org/org/${userId}`
  return api.get(url)
}

// 查询用户所属的组织编码 没有用到
// export const getUserOrganizationCode = () => {
//   const url = `/api/user/org/code/${userId}`
//   return api.get(url)
// }

// 获取订单详情
export const getdetailByDetailId = (orderDetailId) => {
  const url = `/api/orderDetail/getdetailByDetailId/${orderDetailId}`
  return api.get(url)
}
// 申请售后
export const submitAfterSale = (form) => {
  const url = '/api/order/afterSale/purchase/save'
  return api.post(url, form)
}
// 售后订单列表查询
export const afterSaleList = (params) => {
  const url = '/api/order/afterSale/purchase/list'
  return api.get(url, params)
}
// 查询可退换货的数量
export const afterSaleNumEnable = (detailId) => {
  const url = `/api/order/afterSale/afterSaleNumEnable/${detailId}`
  return api.get(url)
}

// 采购人查看售后订单详细信息
export const puchaserGetDetailById = (id) => {
  const url = `/api/order/afterSale/${id}`
  return api.get(url)
}

// 查询是否收藏
export const queryMyCollectByGoodId = (id) => {
  const url = '/special/dictionary/collect/queryMyCollectByGoodId'
  return api.get(url, { goodsId: id })
}

// 加入|取消收藏
export const saveOrUpdateMyCollect = (data) => {
  const url = '/special/dictionary/collect/saveOrUpdateMyCollect'
  return api.post(url, data)
}

// 收藏列表取消收藏
export const updateMyCollect = (data) => {
  const url = '/special/dictionary/collect/updateMyCollect'
  return api.post(url, data)
}
// 根据需求订单ID查询我的需求列表
export const getDemandOrderByIds = (data) => {
  const url = '/api/orderShoppingCart/getByIds'
  return api.post(url, data)
}

// 收藏列表
export const queryMyCollectList = (data) => {
  const url = '/special/dictionary/collect/queryMyCollect'
  return api.get(url, data)
}

// 订单详情中/ 获取商品数据 / 查询订单详情列表
export const getdetailsByOrderId = (orderId) => {
  const url = `/vapi/orderDetail/getdetailsByOrderId/${orderId}`
  return api.get(url)
}

// 订单详情中 查询打印数据
export const getOrderPrint = (id) => {
  const url = `/api/order/getOrderPrintInfo/${id}`
  return api.get(url)
}

// 订单详情
export const orderDetail = (orderId) => {
  const url = `/vapi/shoporder/getInfo/${orderId}`
  return api.get(url)
}

// 查询项目列表
export const proProjectList = (params) => {
  const url = '/api/tPurchaseProProjects/proProjectList'
  return api.get(url, params)
}

// 查询项目及定标信息数据
export const getProjectAndPicketageInfo = (params) => {
  const url = '/api/tPurchaseBidPicketage/getProjectAndPicketageInfo'
  return api.get(url, params)
}

// 根据项目ID查询报价信息及报价详情
export const queryBiddingGoodsListByProject = (params) => {
  const url = '/api/tPurchaseBidBidding/queryBiddingGoodsListByProject'
  return api.get(url, params)
}

// 查询客服信息
export const queryCustom = (data) => {
  const url = `/api/customer/queryCustom`
  return api.get(url, data)
}

// 查询公告列表
export const queryUnitenotices = (data) => {
  const url = `/api/unitenotice/pageQuery`
  return api.get(url, data)
}

// 查询公告详情
export const queryUnitenoticeInfo = (noticeId) => {
  const url = `/api/unitenotice/info?id=${noticeId}`
  return api.get(url)
}

// 查询项目距离报名时间
export const querySecondTime = (data) => {
  const url = `/api/tPurchaseProProjects/querySecondTime`
  return api.get(url, data)
}

// 查询文件URL
export const getFileUrl = (fileType, sourceId) => {
  const url = `/api/file/getUrl/${fileType}/${sourceId}`
  return api.get(url)
}

// 中标日志
export const tPurchaseBidPicketageHisList = (projectId) => {
  const url = `/api/tPurchaseBidPicketageHis/list/${projectId}`
  return api.get(url)
}

// 导出询价结果
export const exportBidResult = (id) => {
  const url = `/api/tPurchaseBidBidding/getBiddingDetailsExport/${id}`
  return api.download(url)
}

// 查询支持预占供应商id
// export const getWhoSupport = () => {
//   const url = `/api/dictionary/queryList?dictionaryKey1=1&dictionaryType=reserve_supplier_support`
//   return api.get(url)
// }

// 修改项目基础数据（上传竞标文件信息）
export const updataTPurchaseProProjects = (data) => {
  const url = '/api/tPurchaseProProjects/'
  return api.put(url, data)
}

// 获取文件url
export const groupAbleOrderList = (goodsId) => {
  const url = `/api/order/groupAbleOrderList?goodsId=${goodsId}`
  return api.get(url)
}

// 修改委托基本信息
export const patchOrderInfo = (params) => {
  const url = `/api/order/order`
  return api.patch(url, params)
}

// 上传完成定标申请表
export const uploadPicketageApplyCompleteSourceId = (projectId, data) => {
  const url = `/api/tPurchaseProProjects/uploadPicketageApplyCompleteSourceId/${projectId}`
  return api.put(url, data)
}

// 采购人补充资质图片
export const purchaserAddAttachment = (form) => {
  const url = '/api/user/purchaser/attachment'
  return api.post(url, form)
}

// 供应商补充资质图片
export const supplierAddAttachment = (form) => {
  const url = '/api/org/supplier/attachment'
  return api.post(url, form)
}

// 导出订单
export const getOrderExport = (params) => {
  let url = '/vapi/shoporder/export'
  if (params) {
    url = url + '?'
    for (const key in params) {
      url = url + key + '=' + params[key] + '&'
    }
    url = url.substring(0, url.length - 1)
  }
  return api.download(url)
}

// 删除直购失败订单
export const deleteFailedOrder = (orderId) => {
  const url = `/api/order/isDeleteById/${orderId}`
  return api.get(url)
}

// 查询库存
export const stocksWithAddress = (data) => {
  const url = '/api/goodsItem/stocksWithAddress'
  return api.post(url, data)
}

// 热词查询
export const hotSearch = (data) => {
  const url = '/api/search/hotSearch'
  return api.get(url, data)
}

// 订单总数与金额
export const getSumPriceAndCount = () => {
  const url = `/api/order/getSumPriceAndCount`
  return api.get(url)
}

// 首页订单数量展示接口
export const getOrderCount = () => {
  const url = `/api/orderStatistics/getOrderCount`
  return api.get(url)
}

//预计送达时间
export const getDeliveryTime = (data) => {
  const url = `/api/goodsItem/getDeliveryTime`
  return api.get(url, data)
}


//购物车列表
export const listbycreatetime = (data) => {
  var userId = tools.localRead('userId');
  const url = '/vapi/cart/listbycreatetime?createUser=' + userId
  return api.get(url)
}



// 导出购物车
export const exportCart = (data) => {
  const url = '/vapi/activity/actcart/export'
  return api.get(url, data)
}

// 下载用户导入模板
export const importTemplate = () => {
  const url = '/vapi/activity/actcart/importTemplate'
  return api.get(url)
}


//订单数量
export const olistNum = () => {
  const url = '/vapi/index/system/order/list'
  return api.get(url)
}

//优选品牌
export const queryList = () => {
  const url = '/vapi/index/brands/queryList'
  return api.get(url)
}



//首页分类楼层
export const selectList = () => {
  const url = '/vapi/index/excellent/selectList'
  return api.get(url)
}



// 朝阳商品搜索
export const cyGoodsSearch = (data) => {
  const url = '/vapi/item/search'
  return api.post(url, data)
}


// 首页轮播图
export const bannerList = () => {
  const url = '/vapi/index/dictionary/list'
  return api.get(url)
}


//首页优选商品楼层
export const searchByIds = (data) => {
  const url = '/vapi/item/searchByIds'
  return api.post(url, data)
}


// 二级三级分类查询
export const searchByCategory = (data) => {
  const url = '/vapi/item/searchByCategory'
  return api.post(url, data)
}

// 优选品牌商品列表
export const searchByBrand = (data) => {
  const url = '/vapi/item/searchByBrand'
  return api.post(url, data)
}




//优选商品查询前台
export const tqualitygoodsgoodsList = (data) => {
  const url = `/vapi/index/tqualitygoods/list`
  return api.get(url, data)
}


// 防疫专区
export const fangyiList = (data) => {
  const url = `/vapi/index/tqualitygoods/listfy`
  return api.get(url, data)
}


// 扶贫专区
export const fupinList = (data) => {
  const url = `/vapi/index/tconsumerAssistance/list`
  return api.get(url, data)
}

//生成正式订单，先预占，在确认
export const createNewOrder = (params) => {
  const url = `/vapi/shoporder/orderApproveResult`
  return api.get(url, params)
}

//本钢领导查看订单
export const purchaseOrderList = (data) => {
  const url = `/vapi/shoporder/purchaseOrderList?pageNum=` + data.pageNum + '&pageSize=' + data.pageSize
  return api.post(url, data)
}


//根据token查询个人资料
export const getUserInfoByToken = (data) => {
  const url = `/special/dictionary/users/selectUserInfoByUserId`
  return api.post(url,data)
}


//查询物流信息
export const getTrack = (params) => {
  const url = `/vapi/supplier/supplierCall/track`
  return api.get(url, params)
}

//本钢确认收货

export const querenshouhuo = (params) => {
  const url = `/vapi/shoporder/receive`
  return api.get(url, params)
}
//钢钢好免登
export const getUserByTokenGGH = (params) => {
  const url = '/vapi/sso/getUserByToken'
  return api.get(url, params)
}
//查询角色
export const getRole = () => {
  const url = '/special/permission/user/infoRole'
  return api.get(url)
}

export const itemZoneList = (params) => {
  const url = `${config.pre}/index/itemZone/list`
  return api.post(url, params)
}

export const itemZoneCreate = (params) => {
  const url = `${config.pre}/index/itemZone/create`
  return api.post(url, params)
}

export const itemZoneRemove = (id) => {
  const url = `${config.pre}/index/itemZone/${id}`
  return api.delete(url)
}

export const itemZoneById = (id) => {
  const url = `${config.pre}/index/itemZone/${id}`
  return api.get(url)
}

export const itemZoneCategoryList = (params) => {
  const url = `${config.pre}/index/itemZoneList/list`
  return api.post(url, params)
}